package com.lhkj.ct.meta.modules.psychology.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lhkj.ct.base.model.dto.PageQuery;
import com.lhkj.ct.base.mybatis.extension.service.BatchHandleService;
import com.lhkj.ct.base.mybatis.extension.service.IPageService;
import com.lhkj.ct.meta.modules.psychology.model.dto.GaugeAllotDto;
import com.lhkj.ct.meta.modules.psychology.model.dto.ScanAllotDto;
import com.lhkj.ct.meta.modules.psychology.model.entity.TblScalePsyRecord;
import com.lhkj.ct.meta.modules.psychology.model.vo.PsyRecordsVo;
import com.lhkj.ct.meta.modules.psychology.model.vo.ViewAnswerVo;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 测验记录 服务类
 * </p>
 *
 * @author jobob
 * @since 2023-10-12
 */
public interface PsyRecordService extends BatchHandleService<TblScalePsyRecord>, IPageService<TblScalePsyRecord> {

    /**
     * 量表分配
     * @param allotDto
     * @return  分配成功人次
     */
    boolean allot(final GaugeAllotDto allotDto);

    /**
     * 测验记录 - 分页
     */
    IPage<PsyRecordsVo> selectPages(PsyRecordsVo psyRecord, PageQuery pageQuery);

    /**
     * 查询登录用户测验记录 - 分页
     */
    IPage<PsyRecordsVo> selectPagesByPatient(PsyRecordsVo psyRecord, PageQuery pageQuery);

    /**
     * 根据分配记录获取量表信息和题目
     * @param allotId 分配记录
     * @param validateSelf 是否校验本人作答
     */
    Map<String, Object> selectScaleWithQuestionsByAllotId(String allotId, boolean validateSelf);

    /**
     * 查看作答结果
     * @param allotId
     * @return
     */
    ViewAnswerVo viewAnswer(String allotId);

    /**
     * 日期范围内按天统计
     * @param start
     * @param end
     * @return
     */
    List<Map<String, Object>> countGroupByDate(LocalDate start, LocalDate end);

    void scanAllot(ScanAllotDto scanAllotDto, HttpServletResponse response) throws IOException;
}
